const express = require("express");
const router = express.Router();
const UserController = require("../controllers/userController");
const { verifyToken, verifyAdmin } = require("../middleware/auth");

// 用户注册
router.post("/register", UserController.createUser);  // 修改为createUser

// 用户登录
router.post("/login", UserController.login);

// 获取当前用户信息
router.get("/me", verifyToken, UserController.getCurrentUser);

// 更新用户信息
router.put("/me", verifyToken, UserController.updateCurrentUser);

// 管理员操作
router.get("/", verifyToken, UserController.getAllUsers);
router.get("/page", verifyToken, UserController.getUsersByPage);  // 新增分页路由
router.get("/:id", verifyToken, UserController.getUserById);
router.put("/:id", verifyToken, UserController.updateUser);
router.delete("/:id", verifyToken, UserController.deleteUser);

module.exports = router;